package com.lihongman.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.lihongman.entity.User;
import com.lihongman.util.DBHelp;
import com.lihongman.util.RowMapper;

public class UserDao {
	
	private DBHelp<User> db = new DBHelp<User>();
	
	public User findByNameAndPwd(String name, String password) {
		String sql = "select id,username,password,juese from t_user where username=? and password=?";
		return db.executeQueryForObject(sql, new UserRowMapper(),name,password);
		
	}
	private class UserRowMapper implements RowMapper<User>{

		public User mapperRow(ResultSet rs) throws SQLException {
			User user = new User();
			user.setId(rs.getInt("id"));
			user.setPassword(rs.getString("password"));
			user.setUsername(rs.getString("username"));
			user.setJuese(rs.getString("juese"));
			return user;
		}
		
	}
}
